package homework01;

public class homework1_1_6 {
    public static void main(String[] args) throws InterruptedException {
        System.out.println("欧几里得算法：31415和14142的最大公约数是 "+gcd(31415, 14142));
        System.out.println("连续整数检查算法：31415和14142的最大公约数是 "+gcd2(31415,14142));
    }


    public static int gcd(int m, int n) {
        while (n != 0) {
            int t = m % n;
            m = n;
            n = t;
        }
        return m;
    }

    public static int gcd2(int m, int n) {
        int t = Math.min(m, n);
        while (m % t != 0 || n % t != 0) {
            t--;
        }
        return t;

    }
}

